package com.atguigu.tms.mock.service.impl;

import com.atguigu.tms.mock.bean.*;
import com.atguigu.tms.mock.mapper.SorterInfoMapper;
import com.atguigu.tms.mock.service.BaseComplexService;
import com.atguigu.tms.mock.service.ExpressCourierComplexService;
import com.atguigu.tms.mock.service.SorterInfoService;
import com.atguigu.tms.mock.service.adv.impl.AdvServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
 * <p>
 * 分拣员 服务实现类
 * </p>
 *
 * @author zhangchen
 * @since 2022-06-24
 */
@Service
public class SorterInfoServiceImpl extends AdvServiceImpl<SorterInfoMapper, SorterInfo> implements SorterInfoService {



    @Autowired
    BaseComplexService baseComplexService;

    @Override
    public List<SorterInfo> initSorter(List<EmployeeInfo> employeeInfoList ) {
        List<SorterInfo> sortInfoList=new ArrayList<>(employeeInfoList.size());
        for (EmployeeInfo employeeInfo : employeeInfoList) {
            SorterInfo sorterInfo= genSorterInfo(  employeeInfo  );
            sortInfoList.add(sorterInfo);
        }
        this.saveOrUpdateBatch(sortInfoList,1000,true);

        return sortInfoList;
    }

    public SorterInfo genSorterInfo(EmployeeInfo employeeInfo  ){
        SorterInfo sorterInfo = new SorterInfo();
        sorterInfo.setEmpId(employeeInfo.getId());
        sorterInfo.setOrgId(employeeInfo.getOrgId());
        sorterInfo.setIsDeleted("0");
        sorterInfo.setCreateTime(employeeInfo.getCreateTime());
        sorterInfo.setEmployeeInfo(employeeInfo);
        return sorterInfo;
    }

    protected String getIdName(){
        return  "empId";
    }


}
